# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=felix
pkgver=2.11.1
pkgrel=0
pkgdesc="Simple TUI file manager with vim-like key mapping"
url="https://kyoheiu.dev/felix/"
# s390x: nix crate doesn't build yet
arch="all !s390x"
license="MIT"
makedepends="
	bzip2-dev
	cargo
	cargo-auditable
	libgit2-dev
	oniguruma-dev
	zlib-ng-dev
	zstd-dev
	"
checkdepends="zoxide"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/kyoheiu/felix/archive/refs/tags/v$pkgver.tar.gz
	use-system-libs.patch
	"

export RUSTONIG_DYNAMIC_LIBONIG=1

prepare() {
	default_prepare

	# Rust target triple.
	local target=$(rustc -vV | sed -n 's/host: //p')

	# Build against system-provided libs
	mkdir -p .cargo
	cat >> .cargo/config.toml <<-EOF
		[target.$target]
		git2 = { rustc-link-lib = ["git2"] }
		z-ng = { rustc-link-lib = ["z-ng"], rustc-cfg = ["zng"] }
	EOF

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 target/release/fx -t "$pkgdir"/usr/bin/
}

sha512sums="
f195b02429fed91552be5c0f712543239e54c549d7944bab3ed743f64b91564366943c36920ee4051ea81103bf3f94ab9b126dd95aaea73adf0905cfe9574ed1  felix-2.11.1.tar.gz
39a1c327594c710af95c420ee2e835a0db54612c0ec89cc639e77c540e26dbd414e289a712562d58ba609ca8dbf5c95e087f5e691b9164909123f100127b1c93  use-system-libs.patch
"
